<include file="Public:head"/>
		<div class="col-xs-12">
			<div class="tabbable">
				<ul class="nav nav-tabs padding-12 tab-color-blue background-blue" id="myTab">
					<li class="active"> <a href="#home" data-toggle="tab">用户组列表</a></li>
					<li> <a href="javascript:;" onclick="add()">添加用户组</a></li>
				</ul>
				<div class="tab-content">
					<table class="layui-table">
						<tr>
							<th>用户组名</th>
							<th>操作</th>
						</tr>
						<foreach name="data" item="v">
							<tr>
								<td>{$v['title']}</td>
								<td> 
									<a href="javascript:;" ruleId="{$v['id']}" ruleTitle="{$v['title']}" onclick="edit(this)">修改</a> |
									<a href="javascript:;" onclick="del('{:U('Admin/Rule/delete_group',array('id'=>$v['id']))}', {$v['id']})">删除</a> | 
									<a href="{:U('Admin/Rule/rule_group',array('id'=>$v['id']))}">分配权限</a> | 
									<a href="{:U('Admin/Rule/check_user',array('group_id'=>$v['id']))}">添加成员</a>
								</td>
							</tr>
						</foreach>
					</table>
				</div>
			</div>
		</div>
		<div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
						<h4 class="modal-title" id="myModalLabel"> 添加用户组</h4>
					</div>
					<div class="modal-body">
						<form id="bjy-form" class="layui-form" action="{:U('Admin/Rule/add_group')}" method="post">
							<div class="layui-form-item">
		                        <label class="layui-form-label">用户组名：</label>
		                        <div class="layui-input-inline">
		                            <input type="text" name="title" placeholder="用户组名" autocomplete="off" class="layui-input">
		                        </div>
		                        <div class="layui-form-mid layui-word-aux"></div>
		                    </div>
		                    <div class="layui-form-item">
		                        <div class="layui-input-block">
		                          <button class="layui-btn" lay-submit lay-filter="addRuleGroup">添加</button>
		                        </div>
		                    </div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<div class="modal fade" id="bjy-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header"> 
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
						<h4 class="modal-title" id="myModalLabel"> 修改用户组</h4>
					</div>
					<div class="modal-body">
						<form id="bjy-form" class="form-inline" action="{:U('Admin/Rule/edit_group')}" method="post"> 
							<input type="hidden" name="id">
							<div class="layui-form-item">
		                        <label class="layui-form-label">用户组名：</label>
		                        <div class="layui-input-inline">
		                            <input type="text" name="title" placeholder="用户组名" autocomplete="off" class="layui-input">
		                        </div>
		                        <div class="layui-form-mid layui-word-aux"></div>
		                    </div>
		                    <div class="layui-form-item">
		                        <div class="layui-input-block">
		                          <button class="layui-btn" lay-submit lay-filter="editRuleGroup">修改</button>
		                        </div>
		                    </div>
						</form>
					</div>
				</div>
			</div>
		</div>
<script>

	$(document).ready(function(){
        layui.use('form', function(){
            var form = layui.form;
            // 验证
            form.verify({
                // money:[/^(([1-9]\d*)|\d)(\.\d{1,2})?$/,"请输入正确的价格！"],
            });      
            //监听提交修改菜单
            form.on('submit(editRuleGroup)', function(data){
                $(data.form).ajaxSubmit({
                    url:"{:U('Admin/Rule/edit_group')}",
                    type: 'post',
                    beforeSubmit:function(ormData,jqForm,options){
                        //加载层-风格4
                        layer.msg('加载中...', {
                          icon: 16,
                          shade: 0.2,
                          time:0,
                        });
                    },
                    success:function(responseText,statusText){
                        layer.closeAll();
                        if(responseText.status == 1){
                            layer.msg(responseText.info, {icon: 6,shade: 0.2,time:1000},function(){
                                location.href = responseText.url;
                            });
                        }else{
                            layer.msg(responseText.info, {icon: 5,shade: 0.2,time:1000});
                        }
                    },
                });
                //layer.msg(JSON.stringify(data.field));
                return false;
            });
            //监听提交添加菜单
            form.on('submit(addRuleGroup)', function(data){
                $(data.form).ajaxSubmit({
                    url:"{:U('Admin/Rule/add_group')}",
                    type: 'post',
                    beforeSubmit:function(ormData,jqForm,options){
                        //加载层-风格4
                        layer.msg('加载中...', {
                          icon: 16,
                          shade: 0.2,
                          time:0,
                        });
                    },
                    success:function(responseText,statusText){
                        layer.closeAll();
                        if(responseText.status == 1){
                            layer.msg(responseText.info, {icon: 6,shade: 0.2,time:1000},function(){
                                location.href = responseText.url;
                            });
                        }else{
                            layer.msg(responseText.info, {icon: 5,shade: 0.2,time:1000});
                        }
                    },
                });
                //layer.msg(JSON.stringify(data.field));
                return false;
            });
        });
    });

	// 添加菜单
	function add(){
		$("input[name='title']").val('');
		$('#bjy-add').modal('show');
	}

	// 修改菜单
	function edit(obj){
		var ruleId=$(obj).attr('ruleId');
		var ruletitle=$(obj).attr('ruletitle');
		$("input[name='id']").val(ruleId);
		$("input[name='title']").val(ruletitle);
		$('#bjy-edit').modal('show');
	}
</script>
<include file="Public:foot"/>